home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / modula2 / 10 < prev    next >
Encoding:
Text File  |  1996-08-06  |  2.0 KB  |  72 lines

  1. Newsgroups: comp.lang.modula2
  2. Path: bcc.ac.uk!news
  3. From: gstark@ifs.org.uk  (Graham Stark)
  4. Subject: ISO I/O question
  5. Sender: news@ucl.ac.uk (Usenet News System)
  6. Message-ID: <1996Jan3.163557.31445@ucl.ac.uk>
  7. Date: Wed, 3 Jan 1996 16:35:57 GMT
  8. Reply-To: gstark@ifs.org.uk  (Graham Stark)
  9. Organization: The Institute for Fiscal Studies
  10. X-Newsreader: IBM NewsReader/2 v1.02
  11.  
  12.  
  13. Happy new year ot you all.
  14.  
  15. I wonder if I could pick all your brains on a wee problem I'm having converting some
  16. code from Topspeed modula-2 to ISO standard M2 (using the GPM compiler for OS/2 EMX).
  17.  
  18. We have the following little TopSpeed function:
  19.  
  20. PROCEDURE EscapeHit() : BOOLEAN;
  21. BEGIN
  22.     RETURN IO.KeyPressed() AND (IO.RdKey() = Escape);
  23. END EscapeHit;
  24.  
  25. This allows you to write things like:
  26.  
  27. REPEAT
  28.   I := I + 1
  29.   .....
  30. UNTIL (I > 10000) OR EscapeHit();
  31.  
  32. This keeps looping until you actually hit esc. (it doesn't
  33. wait at the bottom for a key to be pressed).
  34.  
  35. The question is: can you do something similar using only the
  36. ISO I/O libraries. I thought that a function based on Look()
  37. might do it:
  38.  
  39. PROCEDURE EscapeHit()
  40. VAR OK:BOOLEAN;
  41.     VAR Ch:CHAR;
  42.     Res : IOConsts.ReadResults;
  43. BEGIN
  44.   IOChan.Look( StdChans.InChan() , Ch , Res ); 
  45.   OK := (Res = IOConsts.allRight);
  46.   RETURN OK AND (Ch = Escape);
  47. END EscapeHit;
  48.  
  49. But this causes the program to wait at the end of the loop until a key is
  50. pressed (at least using the GPM implementation, which I'm sure is correct).
  51. On the other hand, if you do hit Escape it does indeed exit the loop.
  52.  
  53. Can anyone tell me what I should be doing here?
  54.  
  55. More generally, is there anywhere a tutorial guide to ISO M2, especially 
  56. the libraries? 
  57.  
  58. As it is,I've had to work out what the libraries do from the comments 
  59. in the DEF files and by trial and error. The standards document itself doesn't
  60. sound like a bundle of laughs.
  61.  
  62. many thanks
  63.  
  64. Graham Stark
  65.  
  66.  
  67. *******************************************************************
  68.  The Institute for Fiscal Studies World Wide Web Server:
  69.   http://www1.ifs.org.uk/
  70. *******************************************************************
  71.  
  72.